package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.BusinessSystemMenuEntity;
import com.jinmdz.fmis.mapper.mapper.provider.BusinessSystemMenuProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 业务系统菜单Mapper
 *
 * @author generator
 * @date 2020-03-18 15:10
 */
public interface BusinessSystemMenuMapper {

    /**
     * 增加BusinessSystemMenu
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @InsertProvider(type = BusinessSystemMenuProvider.class, method = "insertBusinessSystemMenu")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertBusinessSystemMenu(@Param("entity") BusinessSystemMenuEntity entity);

    /**
     * 删除BusinessSystemMenu
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @Update(" update business_system_menu set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForBusinessSystemMenu(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改BusinessSystemMenu
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @UpdateProvider(type = BusinessSystemMenuProvider.class, method = "updateBusinessSystemMenu")
    void updateBusinessSystemMenu(@Param("entity") BusinessSystemMenuEntity entity);

    /**
     * 查询BusinessSystemMenu实体
     *
     * @param id 主键
     * @return BusinessSystemMenuEntity
     * @author generator
     * @date 2020-03-18 15:10
     */
    @Select(" select id,deleted,business_system_id,parent_id,menu_name,menu_route,menu_redirect_route,menu_icon,disable_state,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from business_system_menu where id = #{id} and deleted = 0 limit 1 ")
    BusinessSystemMenuEntity getBusinessSystemMenuById(@Param("id") Integer id);

    /**
     * 查询BusinessSystemMenu列表
     *
     * @param entity 数据实体
     * @return BusinessSystemMenuEntity
     * @author generator
     * @date 2020-03-18 15:10
     */
    @SelectProvider(type = BusinessSystemMenuProvider.class, method = "listBusinessSystemMenu")
    ArrayList<BusinessSystemMenuEntity> listBusinessSystemMenu(@Param("entity") BusinessSystemMenuEntity entity);
}